import request from "@/utils/request";

const env = window.ENV || {
  API_USER: "",
};

//查看组织机构树
export function getOrgTree(params) {
  return request({
    url: env.API_USER + `/v1/org/getOrgTree`,
    method: "GET",
    params: params
  }).then(res => res.data);
}

//根据相关条件模糊分页查询机构树
export function findSysOrgPage(data) {
  return request({
    url: env.API_USER + `/v1/org/findSysOrgPage`,
    method: "POST",
    data: {
      sort: 'desc',
      ...data
    }
  }).then(res => res.data);
}

// 根据主键id查询机构信息
export function findByPrimaryKey(params) {
  return request({
    url: env.API_USER + `/v1/org/findByPrimaryKey`,
    method: "GET",
    params: params
  });
}

//获取全部组织信息
export function findAllOrgApi(params) {
  return request({
    url: env.API_USER + `/v1/org/findAllOrgApi`,
    method: "GET",
    params: params
  });
}

//增加组织机构
export function addSysOrg(data) {
  return request({
    url: env.API_USER + `/v1/org/addSysOrg`,
    method: "POST",
    data: data
  });
}

//修改组织机构
export function updateSysOrg(data) {
  return request({
    url: env.API_USER + `/v1/org/updateSysOrg`,
    method: "POST",
    data: data
  });
}

// 删除组织机构
export function deleteSysOrg(params) {
  return request({
    url: env.API_USER + `/v1/org/deleteSysOrg`,
    method: "DELETE",
    params: params
  }).then(res=>res.data);
}
